﻿﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>订单点检信息维护</title>
  <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
  <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
  <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
  <style>
    .inline-block {
      display: inline-block;
    }

    .divLabel {
      margin-bottom: 5px;
    }

    /* 重写下拉框样式 */
    .select {
      width: 200px;
    }

    .combobox-item {
      height: 32px;
    }

    /* 重写日期框样式 
    .datebox {
      height: 24px !important;
      line-height: 24px !important;
    }*/

    /* 重写文本框样式 */
    #queryZone .textbox-text,
    #dialogQueryZone .textbox-text,
    #processZone .textbox-text {
      line-height: 22px !important;
      height: 22px !important;
    }
  </style>
</head>

<body>
  <div class="panelSection" id="queryZone">
    <div class="easyui-panel " title="查询区域" style="padding:3px 3px 5px;"
      data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
      <div>
        <div class="inline-block">
          <div class="divLabel">主制分厂:</div>
          <select id='ddlFactory' data-options='editable:true' class='easyui-combobox select'
            style="width:160px;"></select>
        </div>

        <div class="inline-block">
          <div class="divLabel">型别:</div>
          <select id='ddlProductfamily' data-options='editable:false' class='easyui-combobox select'
            style="width:160px;"></select>
        </div>

        <div class="inline-block">
          <div class="divLabel">订单号:</div>
          <input id="txtMfgordername" class="easyui-textbox" style="width:140px;" />
        </div>

        <div class="inline-block">
          <div class="divLabel">零件号:</div>
          <input id="txtProductname" class="easyui-textbox" style="width:140px;" />
        </div>

        <div class="inline-block">
          <div class="divLabel">计划完成时间:</div>
          <input id="txtPlannedcompletiondateStart" type="text" class="easyui-datebox"
            style="height: 22px;width: 110px" />
        </div>
        <div class="inline-block">
          <div class="divLabel">至:</div>
          <input id="txtPlannedcompletiondateEnd" type="text" class="easyui-datebox"
            style="height: 22px;width: 110px" />
        </div>

        <div class="inline-block">
          <div class="divLabel">创建时间:</div>
          <input id="txtReceiveDateStart" type="text" class="easyui-datebox" style="height: 22px;width: 110px" />
        </div>
        <div class="inline-block">
          <div class="divLabel">至:</div>
          <input id="txtReceiveDateEnd" type="text" class="easyui-datebox" style="height: 22px;width: 110px" />
        </div>

        <div class="inline-block">
          <div class="divLabel">下发时间:</div>
          <input id="txtSendStartBegin" type="text" class="easyui-datebox" style="height: 22px;width: 110px" />
        </div>
        <div class="inline-block">
          <div class="divLabel">至:</div>
          <input id="txtSendStartEnd" type="text" class="easyui-datebox" style="height: 22px;width: 110px" />
        </div>
      </div>

      <div style="margin-top: 10px;">
        <div class="inline-block">
          <div class="divLabel">下发状态:</div>
          <select id='ddlStatus' value="未下发" data-options='editable:false' class='easyui-combobox select'
            style="width:100px;">
            <option value="请选择">请选择</option>
            <option value="已下发">已下发</option>
            <option value="未下发">未下发</option>
          </select>
        </div>

        <div class="inline-block">
          <div class="divLabel">是否齐套:</div>
          <select id='ddlIsAllSet' data-options='editable:false' class='easyui-combobox select' style="width:100px;">
            <option value="请选择">请选择</option>
            <option value="是">是</option>
            <option value="否">否</option>
          </select>
        </div>

        <div class="inline-block">
          <div class="divLabel">辅材是否齐套:</div>
          <select id='ddlIsAuxSet' data-options='editable:false' class='easyui-combobox select' style="width:100px;">
            <option value="请选择">请选择</option>
            <option value="是">是</option>
            <option value="否">否</option>
            <option value="预齐套">预齐套</option>
          </select>
        </div>

        <div class="inline-block">
          <div class="divLabel">物料是否齐套:</div>
          <select id='ddlIsProductSet' data-options='editable:false' class='easyui-combobox select'
            style="width:100px;">
            <option value="请选择">请选择</option>
            <option value="是">是</option>
            <option value="否">否</option>
            <option value="预齐套">预齐套</option>
          </select>
        </div>

        <div class="inline-block">
          <div class="divLabel">工装是否齐套:</div>
          <select id='ddlIsToolSet' data-options='editable:false' class='easyui-combobox select' style="width:100px;">
            <option value="请选择">请选择</option>
            <option value="是">是</option>
            <option value="否">否</option>
            <option value="预齐套">预齐套</option>
          </select>
        </div>

        <button id="btnSearch" class="easyui-linkbutton" data-options="">查 询</button>
        <button id="btnReset" class="easyui-linkbutton" data-options="">重 置</button>
        <!--<button id="btnExport" class="easyui-linkbutton" data-options="">导 出</button>
        <form id="fm" method="post" enctype="multipart/form-data" style="display:inline-block;">
            <input id="btnImport" class="easyui-filebox" name="fileUpload" data-options="buttonText:'导入',onChange:function(n,o){page.importMfgCheckData(n,o);}" style="width:38px;height: 24px;line-height: 24px;"></input>
        </form>-->
      </div>
    </div>
  </div>

  <div class="panelSection" id="dataGridZone">
    <div class="easyui-panel " title="查询结果" style="padding: 3px;"
      data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
      <div style="background: #fff; margin: 3px 0px 3px 3px">
        <table id="tbGrid" class="easyui-datagrid" style="height: 350px;" data-options="rownumbers:true">
        </table>
        <div id="pp" style="float: right" class="easyui-pagination" data-options="
                      layout:['list','first','prev','next','last','manual','info'],
                        total: 0,
                        showPageList: true,
                        showPageInfo: false,
                        showRefresh: false,
                        pageList:[10,20,50,100,200],
                        afterPageText:'共&nbsp{pages}&nbsp页'">
        </div>
      </div>
    </div>
  </div>

  <div class="panelSection" id="editSec">
    <div class="easyui-panel " title="修改区域" style="padding:3px 3px 5px;"
      data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
      <div class="inline-block">
        <div class="divLabel">辅材是否齐套:</div>
        <select id='ddlAux' data-options='editable:false' class='easyui-combobox select' style="width:120px;">
          <option value="请选择">请选择</option>
          <option value="是">是</option>
          <option value="否">否</option>
          <option value="预齐套">预齐套</option>
        </select>
      </div>

      <div class="inline-block">
        <div class="divLabel">物料是否齐套:</div>
        <select id='ddlProduct' data-options='editable:false' class='easyui-combobox select' style="width:120px;">
          <option value="请选择">请选择</option>
          <option value="是">是</option>
          <option value="否">否</option>
          <option value="预齐套">预齐套</option>
        </select>
      </div>

      <div class="inline-block">
        <div class="divLabel">工装是否齐套:</div>
        <select id='ddlTool' data-options='editable:false' class='easyui-combobox select' style="width:120px;height: 28px;">
          <option value="请选择">请选择</option>
          <option value="是">是</option>
          <option value="否">否</option>
          <option value="预齐套">预齐套</option>
        </select>
      </div>
      <div class="inline-block">
        <div class="divLabel">预齐套时间:</div>
        <input id="ddlEstAllSetDate"  class="easyui-datetimebox select"  style="width:180px;line-height: 28px;height: 28px;"/>
      </div>
    </div>
  </div>

  <div style="margin:5px;">
    <button id="btnCheck" class="easyui-linkbutton" data-options="" onclick="page.mfgOrderCheck()">点检确认</button>
    <button id="btnAllSet" class="easyui-linkbutton" data-options="">一键齐套</button>
    <button id="btnSendStart" class="easyui-linkbutton" data-options="">下 发</button>
    <button id="btnRecycle" class="easyui-linkbutton" data-options="">回 收</button>
    <button id="btnUpdate" class="easyui-linkbutton" data-options="">修 改</button>
    <button id="btnAllSetAndSendStart" class="easyui-linkbutton" data-options="">一键齐套并下发</button>
  </div>
</body>

</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/array.pollyfill.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/dayjs.min.js" type="text/javascript"></script>
<script type="text/javascript">
  /**
   * 创建人：zhunan
   * 日期：2024.11.19
   * 描述：订单点检信息维护
  */
  var page = {
    pagetotal: 0,
    pageNumber: 1,
    pageSize: 10,
    mainUrl: getRootPath() + "/Ashx/MfgorderPrepareMaintPageHandler.ashx", //本页面后台路径
    //初始化页面
    init: function () {
      page.bind();
      page.initData(); //初始化页面数据
      $("#ddlStatus").combobox({ value: '未下发' });
    },
    // 页面事件绑定
    bind: function () {
      // 重点批次进度表格
      $("#tbGrid").datagrid({
        columns: [[
          { field: 'ck', title: '选择', checkbox: true },
          { field: 'mfgorderid', title: 'mfgorderid', hidden: true },
          { field: 'factoryname', title: '主制分厂', width: 100 },
          { field: 'mfgordername', title: '订单号', width: 160 },
          { field: 'qty', title: '数量', width: 80 },
          { field: 'productfamilyname', title: '型别', width: 100 },
          { field: 'productname', title: '零件号', width: 140 },
          {
            field: 'plannedstartdate', title: '计划开始时间', width: 90,
            formatter: function (value) {
              if (value) {
                return value.split('T')[0];
              } else {
                return "";
              }
            }
          },
          {
            field: 'plannedcompletiondate', title: '计划完成时间', width: 90,
            formatter: function (value) {
              if (value) {
                return value.split('T')[0];
              } else {
                return "";
              }
            }
          },
          { field: 'issendstart', title: '是否下发', width: 80 },
          { field: 'fullname', title: '下发人', width: 100 },
          {
            field: 'sendstartdate', title: '下发时间', width: 90,
            formatter: function (value) {
              if (value) {
                return value.split('T')[0];
              } else {
                return "";
              }
            }
          },
//          {
//            field: 'receivedate', title: '创建时间', width: 90,
//            formatter: function (value) {
//              if (value) {
//                return value.split('T')[0];
//              } else {
//                return "";
//              }
//            }
//          },
          { field: 'iscompauxmaterial', title: '辅材是否齐套', width: 100 },
          { field: 'iscompproduct', title: '物料是否齐套', width: 100 },
          { field: 'iscomptool', title: '工装是否齐套', width: 100 },
          { field: 'estallsetdate', title: '预齐套时间', width: 180 }
        ]],
        onLoadSuccess: function (data) {
          $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
            total: page.pagetotal,
            pageSize: page.pageSize,
            pageNumber: page.pageNumber
          });
          customizedEasyuiPagination('pp'); //定制化分页
        },
        onCheck: function (rowIndex, rowData) {
          $('#ddlAux').combobox('setValue', rowData.iscompauxmaterial);
          $('#ddlProduct').combobox('setValue', rowData.iscompproduct);
          $('#ddlTool').combobox('setValue', rowData.iscomptool);
          $('#ddlEstAllSetDate').combobox('setValue', '');
        }
      });

      //分页事件
      $('#pp').pagination({
        onSelectPage: function (pageNumber, pageSize) {
          customizedEasyuiPagination('pp'); //定制化分页
          page.pageSize = pageSize;
          page.pageNumber = pageNumber;
          page.search();
        }
      });

      // 查询按钮
      $("#btnSearch").on("click", function () {
        page.pageNumber = 1;
        page.search();
      });

      // 重置
      $("#btnReset").on('click', function () {
        page.resetData();
      });

      // 导出
      $("#btnExport").on('click', function () {
        page.exportExcel();
      });

      // 一键齐套
      $("#btnAllSet").on("click", function () {
        var selectData = $("#tbGrid").datagrid('getChecked');
        if (selectData.length === 0) {
          displayMessage("请勾选需要一键齐套的记录！", false);
          return;
        }

        $.messager.confirm('确认', '你确认要一键齐套吗?', function (r) {
          if (r) {
            $.ajax({
              type: "post",
              url: page.mainUrl + "?actions=setAllSet",
              data: {
                action: "setAllSet",
                postData: JSON.stringify(selectData),
              },
              cashe: false,
              dataType: 'json',
              success: function (res) {
                if (res.Result) {
                  displayMessage('一键齐套成功', true);
                  $('#tbGrid').datagrid('loadData', []);
                } else {
                  displayMessage(res.Message, false);
                }
              }
            });
          }
        });
      });

      // 下发
      $("#btnSendStart").on("click", function () {
        var selectData = $("#tbGrid").datagrid('getChecked');
        if (selectData.length === 0) {
          displayMessage("请勾选需要下发的记录！", false);
          return;
        }

        for (var i = 0; i < selectData.length; i++) {
          if (selectData[i].iscompauxmaterial !== '是') {
            displayMessage("订单：【" + selectData[i].mfgordername + "】辅材未齐套，不能下发", false);
            return;
          }
          if (selectData[i].iscompproduct !== '是') {
            displayMessage("订单：【" + selectData[i].mfgordername + "】物料未齐套，不能下发", false);
            return;
          }
          if (selectData[i].iscomptool !== '是') {
            displayMessage("订单：【" + selectData[i].mfgordername + "】工装未齐套，不能下发", false);
            return;
          }
        }

        $.messager.confirm('确认', '你确认要下发吗?', function (r) {
          if (r) {
            $.ajax({
              type: "post",
              url: page.mainUrl + "?actions=sendStart",
              data: {
                action: "sendStart",
                postData: JSON.stringify(selectData),
              },
              cashe: false,
              dataType: 'json',
              success: function (res) {
                if (res.Result) {
                  displayMessage('下发成功', true);
                  $('#tbGrid').datagrid('loadData', []);
                } else {
                  displayMessage(res.Message, false);
                }
              }
            });
          }
        });
      });

      // 一键齐套并下发
      $("#btnAllSetAndSendStart").on("click", function () {
        var selectData = $("#tbGrid").datagrid('getChecked');
        if (selectData.length === 0) {
          displayMessage("请勾选需要一键齐套的记录！", false);
          return;
        }

        $.messager.confirm('确认', '你确认要一键齐套并下发吗?', function (r) {
          if (r) {
            $.ajax({
              type: "post",
              url: page.mainUrl + "?actions=setAllSetAndSendStart",
              data: {
                action: "setAllSetAndSendStart",
                postData: JSON.stringify(selectData),
              },
              cashe: false,
              dataType: 'json',
              success: function (res) {
                if (res.Result) {
                  displayMessage('一键齐套并下发成功', true);
                  $('#tbGrid').datagrid('loadData', []);
                } else {
                  displayMessage(res.Message, false);
                }
              }
            });
          }
        });
      })

      // 回收
      $("#btnRecycle").on("click", function () {
        var selectData = $("#tbGrid").datagrid('getChecked');
        if (selectData.length === 0) {
          displayMessage("请勾选需要回收的记录！", false);
          return;
        }

        $.messager.confirm('确认', '你确认要回收吗?', function (r) {
          if (r) {
            $.ajax({
              type: "post",
              url: page.mainUrl + "?actions=recycle",
              data: {
                action: "recycle",
                postData: JSON.stringify(selectData),
              },
              cashe: false,
              dataType: 'json',
              success: function (res) {
                if (res.Result) {
                  displayMessage('回收成功', true);
                  $('#tbGrid').datagrid('loadData', []);
                } else {
                  displayMessage(res.Message, false);
                }
              }
            });
          }
        });
      });

      // 修改
      $("#btnUpdate").on("click", function () {
        var selectData = $("#tbGrid").datagrid('getChecked');
        if (selectData.length === 0) {
          displayMessage("请勾选需要修改的记录！", false);
          return;
        }

        var mapping = [
          { label: '是', value: '1' },
          { label: '否', value: '0' },
          { label: '预齐套', value: '2' }
        ];

        var ddlAux = $('#ddlAux').combobox('getValue');
        var ddlProduct = $('#ddlProduct').combobox('getValue');
        var ddlTool = $('#ddlTool').combobox('getValue');
        var ddlEstAllSetDate = $('#ddlEstAllSetDate').datetimebox('getValue');
        if((ddlAux=='预齐套'||ddlProduct=='预齐套'||ddlTool=='预齐套')&&ddlEstAllSetDate==''){
            displayMessage('预齐套需要录入预齐套时间', false);
            return;
        }

        selectData.forEach(function (item) {
          item.iscompauxmaterial = mapping.filter(function (m) { return m.label === ddlAux })[0].value;
          item.iscompproduct = mapping.filter(function (m) { return m.label === ddlProduct })[0].value;
          item.iscomptool = mapping.filter(function (m) { return m.label === ddlTool })[0].value;
          item.estallsetdate=ddlEstAllSetDate;
        })

        $.messager.confirm('确认', '你确认要修改吗?', function (r) {
          if (!r) { return }
          $.ajax({
            type: "post",
            url: page.mainUrl + "?actions=updateData",
            data: {
              action: "updateData",
              postData: JSON.stringify(selectData),
            },
            cashe: false,
            dataType: 'json',
            success: function (res) {
              if (res.Result) {
                displayMessage('修改成功', true);
                $('#tbGrid').datagrid('loadData', []);
              } else {
                displayMessage(res.Message, false);
              }
            }
          });
        });
      });

      $("#ddlStatus").combobox({
                onChange: function (value) {
                    switch (value) {
                        case "请选择":
                        $("#editSec").show();
                            $("#btnAllSetAndSendStart").show();
                            $("#btnCheck").show();
                            $("#btnAllSet").show();
                            $("#btnSendStart").show();
                            $("#btnUpdate").show();
                            break;
                        case "已下发":
                        $("#editSec").hide();
                            $("#btnAllSetAndSendStart").hide();
                            $("#btnCheck").hide();
                            $("#btnAllSet").hide();
                            $("#btnSendStart").hide();
                            $("#btnUpdate").hide();
                            break;
                        default:                 
                        $("#editSec").show();
                            $("#btnAllSetAndSendStart").show();
                            $("#btnCheck").show();
                            $("#btnAllSet").show();
                            $("#btnSendStart").show();
                            $("#btnUpdate").show();
                            break;
                    }
                    page.clearPage(false, true);
                }
            });

    },
    // 初始化页面
    initData: function () {
      page.getFactory();
      page.getProductfamily();
    },
    // 查询
    search: function () {
      var formData = {
        action: "getData",
        pageSize: page.pageSize,
        pageNumber: page.pageNumber,
        factoryid: $('#ddlFactory').combobox('getValue'),//主制分厂
        productfamilyname: $('#ddlProductfamily').combobox('getValue'),//型别
        mfgordername: $("#txtMfgordername").textbox('getValue'),//订单号
        plannedcompletiondateStart: $("#txtPlannedcompletiondateStart").textbox('getValue'),//计划完成时间
        plannedcompletiondateEnd: $("#txtPlannedcompletiondateEnd").textbox('getValue'),
        productname: $("#txtProductname").textbox('getValue'),//零件号
        receiveDateStart: $("#txtReceiveDateStart").textbox('getValue'),//创建时间
        receiveDateEnd: $("#txtReceiveDateEnd").textbox('getValue'),
        sendStartBegin: $("#txtSendStartBegin").textbox('getValue'),//下发时间
        sendStartEnd: $("#txtSendStartEnd").textbox('getValue'),
        status: $('#ddlStatus').combobox('getValue'),//下发状态
        isAllSet: $('#ddlIsAllSet').combobox('getValue'),//是否齐套
        isAuxSet: $('#ddlIsAuxSet').combobox('getValue'),//辅材是否齐套
        isProductSet: $('#ddlIsProductSet').combobox('getValue'),//物料是否齐套
        isToolSet: $('#ddlIsToolSet').combobox('getValue')//工装是否齐套
      };

      $.ajax({
        type: "Post",
        url: page.mainUrl + "?actions=getData",
        data: formData,
        cashe: false,
        async: true,
        beforeSend: function () {
          $('#tbGrid').datagrid('loading');
          $(this).attr("disabled", "disabled"); //禁用按钮
        },
        success: function (data) {
          $('#tbGrid').datagrid('loaded');
          $(this).removeAttr("disabled"); //恢复按钮
          var result = JSON.parse(data);
          if (result.Result) {
            //给分页对象赋值
            page.pagetotal = result.RowCount;
            $('#tbGrid').datagrid('loadData', { total: result.RowCount, rows: result.DBTable });
          } else {
            displayMessage(result.Message, false);
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          $('#tbGrid').datagrid('loaded');
          $(this).removeAttr("disabled"); //恢复按钮
          alert(XMLHttpRequest.responseText);
        }
      });
    },
    // 获取分厂列表
    getFactory: function () {
      $.ajax({
        type: "post",
        url: getRootPath() + "/Ashx/ApsHandler/EmployeeMaintPage.ashx?actions=getFactory",
        data: { action: "GetFactory" },
        cashe: false,
        dataType: 'json',
        success: function (res) {
          if (res.Result) {
            // 绑定弹出框分厂下拉框
            $("#ddlFactory").combobox({
              valueField: 'factoryid',
              textField: 'factoryname',
              panelHeight: 200,
              data: res.DBTable
            });

            $.ajax({
              type: "post",
              url: page.mainUrl + "?actions=getUserInfo",
              data: { action: "getUserInfo" },
              cashe: false,
              dataType: 'json',
              success: function (res) {
                if (res.Result) {
                  $("#ddlFactory").combobox('select', res.ReturnData.FactoryID);
                  $('#ddlFactory').combobox('disable');
                } else {
                  displayMessage(res.Message, false);
                }
              }
            });
          }
        }
      });
    },
    // 获取机型
    getProductfamily: function () {
      $.ajax({
        type: "post",
        url: page.mainUrl + "?=actions=getProductfamily",
        data: { action: "getProductfamily" },
        cashe: false,
        dataType: 'json',
        success: function (res) {
          if (res.Result) {
            $("#ddlProductfamily").combobox({
              valueField: 'productfamilyname',
              textField: 'productfamilyname',
              panelHeight: 200,
              data: res.DBTable
            });
          }
        }
      });
    },
    // 重置
    resetData: function () {
      // $('#ddlFactory').combobox('select', '');
      $('#ddlProductfamily').combobox('select', '');
      $("#txtMfgordername").textbox('clear');
      $("#txtPlannedcompletiondateStart").textbox('clear');
      $("#txtPlannedcompletiondateEnd").textbox('clear');
      $("#txtProductname").textbox('clear');
      $("#txtReceiveDateStart").textbox('clear');
      $("#txtReceiveDateEnd").textbox('clear');
      $("#txtSendStartBegin").textbox('clear');
      $("#txtSendStartEnd").textbox('clear');
      $("#ddlStatus").combobox('select', '未下发');
      $("#ddlIsAllSet").combobox('select', '请选择');
      $("#ddlIsAuxSet").combobox('select', '请选择');
      $("#ddlIsProductSet").combobox('select', '请选择');
      $("#ddlIsToolSet").combobox('select', '请选择');

      $("#tbGrid").datagrid('loadData', { total: 0, rows: [] });
      page.pageNumber = 1;
      page.pageSize = 10;

      $('#pp').pagination('refresh', { // 改变选项并刷新分页栏信息
        total: 0,
        pageNumber: 1,
        pageSize: 10
      });

      var list = ['#ddlAux', '#ddlProduct', '#ddlTool'];
      for (var index = 0; index < list.length; index++) {
        $(list[index]).combobox('select', '请选择');
      }
    },
    // 导出
    exportExcel: function () {
      var formData = {
        action: "exportExcel",
        factoryid: $('#ddlFactory').combobox('getValue'),//主制分厂
        productfamilyname: $('#ddlProductfamily').combobox('getValue'),//型别
        mfgordername: $("#txtMfgordername").textbox('getValue'),//订单号
        plannedcompletiondateStart: $("#txtPlannedcompletiondateStart").textbox('getValue'),//计划完成时间
        plannedcompletiondateEnd: $("#txtPlannedcompletiondateEnd").textbox('getValue'),
        productname: $("#txtProductname").textbox('getValue'),//零件号
        receiveDateStart: $("#txtReceiveDateStart").textbox('getValue'),//创建时间
        receiveDateEnd: $("#txtReceiveDateEnd").textbox('getValue'),
        sendStartBegin: $("#txtSendStartBegin").textbox('getValue'),//下发时间
        sendStartEnd: $("#txtSendStartEnd").textbox('getValue'),
        status: $('#ddlStatus').combobox('getValue'),//下发状态
        isAllSet: $('#ddlIsAllSet').combobox('getValue'),//是否齐套
        isAuxSet: $('#ddlIsAuxSet').combobox('getValue'),//辅材是否齐套
        isProductSet: $('#ddlIsProductSet').combobox('getValue'),//物料是否齐套
        isToolSet: $('#ddlIsToolSet').combobox('getValue')//工装是否齐套
      };

      $.ajax({
        type: "Post",
        url: page.mainUrl + "?actions=exportExcel",
        data: formData,
        cashe: false,
        async: true,
        beforeSend: function () {
          $('#tbGrid').datagrid('loading');
          $(this).attr("disabled", "disabled"); //禁用按钮
        },
        success: function (data) {
          $('#tbGrid').datagrid('loaded');
          $(this).removeAttr("disabled"); //恢复按钮
          var result = JSON.parse(data);
          if (result.Result) {
            //通过创建a标签实现
            var link = document.createElement("a");
            link.href = result.ReturnData.url;
            //对下载的文件命名
            link.download = result.ReturnData.filename;
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
          } else {
            displayMessage(result.Message, false);
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          $('#tbGrid').datagrid('loaded');
          $(this).removeAttr("disabled"); //恢复按钮
          alert(XMLHttpRequest.responseText);
        }
      });

    },
    //订单点检
    mfgOrderCheck:function(){
        var selectData = $("#tbGrid").datagrid('getChecked');
        if (selectData.length === 0) {
          displayMessage("请勾选需要点检的记录！", false);
          return;
        }
       page.post({action:"MfgOrderCheck", data: JSON.stringify(selectData)}, function (res) {
            if(res.Result){page.search();}
           displayMessage(res.Message, res.Result)
        });

    },
    //导入数据
    importMfgCheckData:function(n,o){
        if(o!=""){return;}
            if ($('#btnImport').filebox('getValue') != "") {
                clearMessage();
                $('#fm').form('submit', {
                    url: page.mainUrl + "?action=ImportMfgCheckData",
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        $('#btnImport').filebox('clear');
                        var res = JSON.parse(result); 
                        if(res.Result){page.search();}
                        displayMessage(res.Message, res.Result);
                    }
                });
            }

    },
    //post数据
    post: function (param, callback) {
        $.ajax({
            type: "Post",
            url: page.mainUrl,
            data: param,
            cashe: false,
            async: true,
            dataType: "json",
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (data) {
                $.messager.progress('close');
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    }
  };

  $(function () {
    page.init();
  });
</script>